package com.passion.mq.util;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 类描述：rocketmq工具类
 *
 * @author ZhuYin
 * @since 2024年12月17日
 */
@Component
@ConditionalOnProperty(prefix = "archives.mq", name = "type", havingValue = "rocketmq")
public class RocketMqUtil implements ApplicationContextAware {

    private static RocketMQTemplate rocketMQTemplate;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        RocketMqUtil.rocketMQTemplate = applicationContext.getBean(RocketMQTemplate.class);
    }

}
